<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>分拣任务添加</h2>
    </div>
    <form action="{:U('missionadd')}" method="post" enctype="multipart/form-data" class="form-horizontal">
        <input type="hidden" name="heheplanid" value="{$heheplanid}">
        <div class="form-item">
            <label class="item-label">成品选择</label>
            <div class="controls">
                <div class="change">
                    <select select2 style="height: 30px; width:300px;" name="BIN">
                        <option value="">请选择...</option>
                        <volist name="list" id="vo">
                            <option value="{$vo.BIN}">{$vo.BIN}/{$vo.pname}/{$vo.spec}</option>
                        </volist>
                    </select>
                </div>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">原料选择</label>
            <div class="controls">
                <div class="change">
                    <select select2 style="height: 30px; width:300px;" name="originalBIN" onchange="getData()">
                        <option value="">请选择...</option>
                        <volist name="_list" id="vl">
                            <option value="{$vl.BIN}" >{$vl.BIN}/{$vl.pname}/{$vl.spec}</option>
                        </volist>
                    </select>
                </div>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">原料批次</label>
            <div class="controls">
                <div class="change">
                    <select select2 style="height: 30px; width:300px;" name="warn_batch">
                        <option value="">请选择...</option>
                        <!--<volist name="_lista" id="vla">-->
                            <!--<option value="{$vla.warn_batch}" >{$vla.warn_batch}/{$vla.BIN}/{$vla.pname}/数量：{$vla.cnt}</option>-->
                        <!--</volist>-->
                    </select>
                </div>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">需要分拣数量</label>
            <div class="controls">
                <input type="text" class="text input-large" name="plancnt" value="{$data.plancnt}">
            </div>
        </div>
        <div class="form-item">
            <button class="btn submit-btn  ajax-post" id="submit" type="submit" target-form="form-horizontal">创 建</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);
                    return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('Sort/planindex')}');

        function getData(){
            var originalBIN=$("select[name=originalBIN]").val();
            $.ajax({
                url:'index.php?s=admin/Sort/getoriginbatch',
                data:{'originalBIN':originalBIN},
                success:function(res){
                    $("select[name=warn_batch] option:gt(0)").remove();
                  for(var i=0;i<res.length;i++){
                    var option=$("<option value="+res[i]['warn_batch']+" >"+res[i]['BIN']+"/批次:"+res[i]['warn_batch']+"/"+res[i]['pname']+"/"+res[i]['cnt']+"</option>");
                      $("select[name=warn_batch]").append(option);
                  }
                }
            })
        }
    </script>
</block>